package com.mgfireworks.mgplatform;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.mgfireworks.mgplatform.mgadmin.constants.Constant;
import com.mgfireworks.mgplatform.mgadmin.user.UserService;
import com.mgfireworks.mgplatform.mgadmin.user.model.User;

import cn.hn.java.summer.exception.BusinessException;

@Controller
@RequestMapping("/")
public class IndexController extends BaseController {

	@Autowired
	UserService userService;
	
	/**
	 * 登录页面
	 */
	@RequestMapping(value="/login",method=RequestMethod.GET)
	public void login(){
	}
	
	/**
	 * 提交登录
	 * @throws BusinessException 
	 */
	@RequestMapping(value="/login",method=RequestMethod.POST)
	public void postLogin(User u) throws BusinessException{
		addSessionAttribute(Constant.USER_SESSION_KEY, userService.login(u));
		redirectTo("/index");
	}
	
	/**
	 * 首页
	 */
	@RequestMapping("/index")
	public void index(){
	}
}
